﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameServer.Virtual_Objects;

namespace GameServer.Networking.Handlers
{
    class HANDLE_DELETE_WEAPON : PacketHandler
    {
        public override void Handle(Virtual_Objects.User.virtualUser User)
        {
            try
            {
                string RemoveItem = getNextBlock();
                int InventoryLength = int.Parse(getNextBlock());

                if (User.hasItem(RemoveItem))
                {
                    DB.runQuery("DELETE FROM inventory WHERE ownerid='" + User.UserID + "' AND itemcode='" + RemoveItem + "'");
                    User.Inventory = new InventoryItem[35];
                    User.LoadItems();
                    for (int I = 0; I < 5; I++)
                    {
                        if (User.Equipment[I, 5].Contains("-"))
                        {
                            User.Equipment[I, 5] = "^";
                        }
                    }
                    User.send(new Packets.PACKET_DELETE_WEAPON(User, RemoveItem));
                    User.send(new Packets.PACKET_CREDITS(User));
                }
                else
                    User.disconnect();
            }
            catch { }
        }
    }
}